﻿/************************************************************************************
 * @author   wangjian
 *  大众三辆车子的控制脚本
************************************************************************************/

using System;
using UnityEngine;
using System.Collections.Generic;


public class ManyCarController:MonoBehaviour {

	public static ManyCarController instace;
	public GameObject cloneObject;
	public List<CarObjectInteraction> list = new List<CarObjectInteraction>();
	public HandSuckBall handSuckBall;

	public void Start(){
		instace = this;
	}
	public void OnGUI(){
		if(GUILayout.Button("生成三个模型")){
			CreateThree ();
		}

		if(GUILayout.Button("抓取小车")){


		}

		if(GUILayout.Button("抛小车")){
			handSuckBall.HandRig.AddForce (0,800, 800);

			//handSuckBall.grabCarobject.ThrowCar(Vector3.zero,Vector3.zero);
		}

		if(GUILayout.Button("重置功能")){

			for(int i = 0 ;i< 3 ;i ++){
				list [i].Rest ();
			}
		}

	}

	void CreateThree(){
		for (int i = 0; i < 3; i++) {
			GameObject o = Instantiate (cloneObject);
			o.gameObject.name = "Car" + i;
			o.SetActive (true);
			o.transform.position = new Vector3 (-3+i*3, 5,0);

			list.Add (o.GetComponent<CarObjectInteraction> ());
		}

	}


}



